<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://app.kanasinfo.com/jsp/taglib/functions" prefix="kafn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<jsp:useBean id="now" class="java.util.Date" />
<script type="text/javascript">
//<![CDATA[
(function(){
	if(typeof SysAdminAbout === "undefined" ){
		SysAdminAbout = {
			refreshDateTime:function(){
				var t = SysAdminAbout._duringTime*1-SysAdminAbout._serverTime*1+(new Date()).getTime()*1;
				dojo.byId("td_appCurrentTime").innerHTML = new Date((new Date()).getTime()*1-SysAdminAbout._clientTime*1+SysAdminAbout._serverTime*1);
				var d = parseInt(t/(3600000*24));
				t = t - d * 3600000*24;
				var h = parseInt(t/3600000);
				t = t - h * 3600000;
				var m = parseInt(t/60000);
				t = t - m * 60000;
				var s = parseInt(t/1000);
				t = t - s * 1000;
				t = "a00" + t;
				dojo.byId("td_appRunDuring").innerHTML = d+" days "+h+" hours "+m+" minutes - "+s+"."+t.substring(t.length-3,t.length)+"s";
			},
			retrieveMemory:function(){
				dojo.xhrGet({
					handleAs:'json',
					url:"${pageContext.request.contextPath}/cgi/app/health/jdkmemory.json",
					headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},
					load:function(r){
						var pb = dijit.byId("about_pb_jdkmemory");
						pb.set("maximum",r.max);
						pb.set("value",r.total-r.free);
						pb.set("label",parseInt((r.total-r.free)/1048576)+" / "+parseInt(r.max/1048576)+" (MB)");
					}
				});
			}
		};
	};
	if(SysAdminAbout.handleTime)clearInterval(SysAdminAbout.handleTime);
	if(SysAdminAbout.handleMem)clearInterval(SysAdminAbout.handleMem);
	SysAdminAbout._serverTime='${now.time}';
	SysAdminAbout._duringTime='${kafn:duringTime(pageContext.servletContext)}';
	SysAdminAbout._clientTime=(new Date()).getTime();
	SysAdminAbout.handleTime = setInterval("SysAdminAbout.refreshDateTime();",125);
	SysAdminAbout.handleMem = setInterval("SysAdminAbout.retrieveMemory();",60000);
	SysAdminAbout.retrieveMemory();
	
	$kdom.appendDojoProp("cp_about_nav","content","<img class=\"icon_s_admin icon_s_admin_org_many\" src=\"${pageContext.request.contextPath}/assets/images/blank.gif\" /><span>"+SysAdmin._resource.about+"</span>");
	var ids = ['aboutApp','appName','appVersion','appStartupDate','appRunDuring','appCurrentUser','appCurrentTime',
	           'hardwareInfo','availableProcessors','networkInterface','macAddress','physicalMemory',
	           'aboutLicense','licenseTo','licenseExp','licenseMaxUser','licenseProduct','licenseMac',
	           'aboutPlat','osName','osVersion','osServicePack','osArch',
	           'jdkVendor','jdkName','jdkVersion','jdkArch','servletContextInfo','jdkMemoryStat'];
	var dom;
	for(var k in ids)
		dojo.query("[id="+ids[k]+"]").forEach(function(node, index, array){node.innerHTML = SysAdmin._resource[ids[k]]+KppModule.commonResource.colon;});
})();
//]]>
</script>

<div data-dojo-type="dijit.layout.BorderContainer" class="contentWrapper" style="margin:-2px;height:100%">
	<div id="cp_about_nav" data-dojo-type="dijit.layout.ContentPane"  data-dojo-props="region:'top'" class="contentWrapperRight contentPaneNav" style="border:none;margin:-5px;padding:10px 0 10px 10px;background-color:transparent">
	</div>
	<div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" 
		style="border:1px solid #E0E0E0;background-color:#F7F7F7;margin:0 3px;" >
		<table width="100%" >
			<tr valign="top">
				<td width="50%">
					<div class="titlebar_gray" id="aboutApp">Application Information</div>
					<table cellspacing="0" width="100%" class="info">
						<tr>
							<td align="right" id="appName">name: </td>
							<td>${kafn:applicationName(pageContext.servletContext)}</td>
						</tr>
						<tr>
							<td align="right" id="appVersion">version: </td>
							<td>${kafn:applicationVersion(pageContext.servletContext)}</td>
						</tr>
						<tr>
							<td align="right" id="appStartupDate">startup date: </td>
							<td>${kafn:startupDate(pageContext.servletContext,"yyyy-MM-dd HH:mm:ss")}</td>
						</tr>
						<tr>
							<td align="right" id="appRunDuring">during: </td>
							<td id="td_appRunDuring"></td>
						</tr>
						<tr>
							<td align="right" id="appCurrentUser">current user: </td>
							<td><sec:authentication property="principal" var="authentication"/>${authentication.username}</td>
						</tr>
						<tr>
							<td align="right" id="appCurrentTime">current time: </td>
							<td id="td_appCurrentTime"></td>
						</tr>
					</table><br />
					<div class="titlebar_gray" id="hardwareInfo">Hardware Information</div>
					<table cellspacing="0" width="100%" class="info">
						<tr>
							<td align="right" id="availableProcessors">Available Processors: </td>
							<td><%=Runtime.getRuntime().availableProcessors()%></td>
						</tr>
						<tr>
							<td align="right" id="physicalMemory">Physical Memory: </td>
							<td>${kafn:totalPhysicalMemorySize()}</td>
						</tr>
						<c:forEach items="${kafn:networkInterfaces()}" var="ni">
						<tr>
							<td align="right" id="networkInterface" style="border-bottom:none">Network Interface: </td>
							<td style="border-bottom:none">${ni.displayName}</td>
						</tr>
						<tr>
							<td align="right" id="macAddress">MAC Address: </td>
							<td>${ni.macAddress}</td>
						</tr>
						</c:forEach>
					</table>
				</td>
				<td>&nbsp;</td>
				<td width="50%">
					<div class="titlebar_gray" id="aboutPlat">Platform Information</div>
					<table cellspacing="0" width="100%" class="info">
						<tr>
							<td align="right" id="osName">os name: </td>
							<td><%=System.getProperty("os.name")%></td>
						</tr>
						<tr>
							<td align="right" id="osVersion">os version: </td>
							<td><%=System.getProperty("os.version")%></td>
						</tr>
						<tr>
							<td align="right" id="osServicePack">os service pack: </td>
							<td><%=System.getProperty("sun.os.patch.level")%></td>
						</tr>
						<tr>
							<td align="right" id="osArch">os arch: </td>
							<td><%=System.getProperty("os.arch")%></td>
						</tr>
						<tr>
							<td align="right" id="jdkVendor">jdk vendor: </td>
							<td><%=System.getProperty("java.vm.vendor")%></td>
						</tr>
						<tr>
							<td align="right" id="jdkName">jdk name: </td>
							<td><%=System.getProperty("java.vm.name")%></td>
						</tr>
						<tr>
							<td align="right" id="jdkVersion">jdk version: </td>
							<td><%=System.getProperty("java.vm.version")%></td>
						</tr>
						<tr>
							<td align="right" id="jdkArch">jdk data model: </td>
							<td><%=System.getProperty("sun.arch.data.model")%></td>
						</tr>
						<tr>
							<td align="right" id="servletContextInfo">servlet container: </td>
							<td><%=application.getServerInfo()%></td>
						</tr>
						<tr>
							<td align="right" id="jdkMemoryStat">jdk memory stat: </td>
							<td><div id="about_pb_jdkmemory" data-dojo-type="dijit.ProgressBar" style="width:150px" ></div>
							</td>
						</tr>
					</table><br />
					<div class="titlebar_gray" id="aboutLicense">License Information</div>
					<table cellspacing="0" width="100%" class="info">
						<tr>
							<td align="right" id="licenseTo">license to: </td>
							<td>no limited</td>
						</tr>
						<tr>
							<td align="right" id="licenseExp">license exp: </td>
							<td>no limited</td>
						</tr>
						<tr>
							<td align="right" id="licenseMaxUser">max users: </td>
							<td>no limited</td>
						</tr>
						<tr>
							<td align="right" id="licenseProduct">product: </td>
							<td>no limited</td>
						</tr>
						<tr>
							<td align="right" id="licenseMac">mac address: </td>
							<td>no limited &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</div>
</div>